<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('修改角色')" />
	<th:block th:include="include :: bootstrap-select-css" />
</head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form enctype="multipart/form-data" class="form-horizontal m" id="form-role-edit" th:object="${obj}">
			<input name="id" id="id" type="hidden" th:value="*{id}"/>
			<div class="form-group">
				<label class="col-sm-3 control-label ">标题：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="title" id="title" th:value="*{title}" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label ">长度(公里)：</label>
				<div class="col-sm-8">
					<input class="form-control" type="number" name="prosess" id="prosess" th:value="*{prosess}" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label ">地区;</label>
				<div class="col-sm-8" id="city_china_val">
				<select id="province" class="province" th:data-value="*{province}" data-first-title="选择省" disabled="disabled"></select>
<select class="city" id="city" th:data-value="*{city}" data-first-title="选择市" disabled="disabled"></select>
<select class="area" id="county" th:data-value="*{county}" data-first-title="选择地区" disabled="disabled"></select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label ">logo：</label>
				<div class="col-sm-8">
					<input class="form-control" type="file" name="logo" id="logo" th:value="*{logo}" >
					<img  th:src="@{${'\\'+obj.logo}}" style="height: 120px;height: 120px;" onerror="this.src='/static/img/noimage.jpg'" />
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label ">版权：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="copyright" id="copyright" th:value="*{copyright}" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label ">数据代码：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="code" id="code" th:value="*{code}" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">备注：</label>
				<div class="col-sm-8">
					<textarea class="form-control" id="remark" name="remark" th:text="*{remark}"></textarea>
				</div>
			</div>
		</form>
	</div>
	<th:block th:include="include :: footer" />
	<th:block th:include="include :: bootstrap-select-js" />
	<script type="text/javascript" th:src="@{/js/jquery.cxselect.min.js}"></script>
	<script type="text/javascript">

	$('#city_china_val').cxSelect({
		url: '/static/js/cityData.min.json',
		selects: ['province', 'city', 'area'],

		nodata: 'none'

	});
	
		function submitHandler() {
	        if ($.validate.form()) {
	        	var formData = new FormData();
	        	formData.append("id",$('#id').val());
	        	formData.append("title",$('#title').val());
	        	formData.append("prosess",$('#prosess').val());
	        	formData.append("copyright",$('#copyright').val());
	        	formData.append("code",$('#code').val());
	        	formData.append("remark",$('#remark').val());
	        	formData.append("province",$('#province').val());
	        	formData.append("city",$('#city').val());
	        	formData.append("county",$('#county').val());
	        	if($('#logo')[0].files[0]!=undefined){
	        		formData.append("logo",$('#logo')[0].files[0]);
	        	}
	        	
	        	$.ajax({
	        	    url: 'save',
	        	    type: 'POST',
	        	    cache: false,
	        	    data: formData,
	        	    processData: false,
	        	    contentType: false
	        	}).done(function(res) {
	        		$.operate.successCallback(res);
	        	}).fail(function(res) {});
	        }
	    }
	</script>
</body>
</html>
